<? 
	session_start();
	include ('conn.php');
	$db = get_conn();
	
  if ($_POST['Agregar']!=""){
  	
	
	$sql = "INSERT INTO modulos (name,link,id_category,target,nivel,description,mostrar,file) VALUES 
	(\"".$_POST['name']."\",\"".$_POST['link']."\",".$_POST['id_category'].",\"".$_POST['target']."\",
	".$_POST['nivel'].",\"".$_POST['description']."\",\"".$_POST['mostrar']."\",\"".$_POST['file']."\")";	
	
	
	$result = mysql_query($sql);
	if($result){
		do_redirect('../modulos.php');	
	}else{
		error_handling(__FUNCTION__.$sql,mysql_error());
	}				  
  }//Agregar
  
  if ($_POST['Actualizar']!=""){

	$sql = "update modulos set name=\"".$_POST['name']."\",link=\"".$_POST['link']."\",id_category=".$_POST['id_category'].",
			target=\"".$_POST['target']."\",nivel=".$_POST['nivel'].",description=\"".$_POST['description']."\",mostrar=\"".$_POST['mostrar']."\",file=\"".$_POST['file']."\"					
					 where id_modulo=".$_POST['id_modulo'];
	 
	$result = mysql_query($sql);
	if($result){
		do_redirect('../modulos.php');	
	}else{
		error_handling(__FUNCTION__.$sql,mysql_error());
	}				  
  }//update
  
  
  if ($_POST['Eliminar']!=""){
	$sql = "delete from modulos where id_modulo=".$_POST['id_modulo'];
	$result = mysql_query($sql);
	if($result){
		do_redirect('../modulos.php');	
	}else{
		error_handling(__FUNCTION__.$sql,mysql_error());
	}				  
  }//delete
  
  
  if ($_POST['Nuevo']!=""){
		do_redirect('../modulos.php');	
  }//nuevo 
?>
  
